package com.wlsk.license.dto;

import com.wlsk.license.common.exception.BusinessException;
import com.wlsk.license.common.utils.ValidationUtils;
import org.apache.commons.lang3.ArrayUtils;

import javax.validation.groups.Default;

/**
 * @description: 请求参数基类
 * @author: liuzhangbin
 * @date: 2025/2/17
 */
public class BaseReqDto extends BaseDto {

    /**
     * 参数校验.
     */
    public void valid(Class<?>... groups) throws BusinessException {

        this.validate(this, groups);
    }

    /**
     * JSR303校验.
     */
    protected final void validate(Object object, Class<?>... groups) throws BusinessException {
        if (0 == groups.length) {
            groups = ArrayUtils.add(groups, Default.class);
        }
        ValidationUtils.validate(object, groups);
    }

}
